﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XtremBiking.Logica.Repositorio
{
    internal static class RoutineTypesManagement
    {

        internal static List<DTO.RoutineType> GetRoutineTypes() 
        {
            List<Entidades.TiposRutina> routineTypes = null;
            DTO.RoutineType routineTypeDTO = null;
            List<DTO.RoutineType> routineTypesListDTO = null;

            using (Entidades.XBEntities ctx = new Entidades.XBEntities())
            {
                routineTypes = ctx.TiposRutina.ToList();

                if (routineTypes != null )
                {
                    routineTypesListDTO = new List<DTO.RoutineType>();
                    foreach (Entidades.TiposRutina item in routineTypes)
                    {
                        routineTypeDTO = new DTO.RoutineType()
                        {
                            RoutineTypeId = item.IdTipoRutina,
                            Name = item.Nombre
                        };
                        routineTypesListDTO.Add(routineTypeDTO);
                    }

                }
            }
            return routineTypesListDTO;
        }
    }
}
